#include "StdAfx.h"
#include "AltiumCircuitNote.h"



CAltiumCircuitNote::CAltiumCircuitNote( void )
{
	m_szAuthor = _T("");
	m_bCollapsed = false;
}

CAltiumCircuitNote::CAltiumCircuitNote( const CAltiumCircuitNote* pNote )
	:CCircuitTextFrame(pNote)
{
	m_szAuthor = pNote->GetAuthor();
	m_bCollapsed = pNote->IsCollapsed();
}

CAltiumCircuitNote::CAltiumCircuitNote( CICircuit* pICircuit )
	:CCircuitTextFrame(pICircuit)
{
	m_szAuthor = _T("");
	m_bCollapsed = false;
}

CAltiumCircuitNote::~CAltiumCircuitNote( void )
{

}

void CAltiumCircuitNote::Serialize( CArchive & ar )
{
	if (ar.IsStoring())
	{
		CObj::WriteString(ar,m_szAuthor);
		ar << m_bCollapsed;
	}
	else
	{
		CObj::ReadString(ar,m_szAuthor);
		ar >> m_bCollapsed;
	}
	CCircuitTextFrame::Serialize(ar);
}

CObj * CAltiumCircuitNote::Clone() const
{
	return new CAltiumCircuitNote(this);
}

CDisplayObj * CAltiumCircuitNote::CreateDisplayObj( long lLayerId )
{
	CAltiumCircuitNoteDisObj* pDisObj = new CAltiumCircuitNoteDisObj(this);
	pDisObj->SetLayerId(lLayerId);
	return pDisObj;
}

void CAltiumCircuitNote::CalcBox()
{
	if (m_bCollapsed)
	{
		double deta = 10.0;
		m_minX = m_dblStartPosX;
		m_minY = m_dblEndPosY-deta;
		m_maxX = m_dblStartPosX+deta;
		m_maxY = m_dblEndPosY;
	}
	else
	{
		CCircuitTextFrame::CalcBox();
	}
}

eCircuitUnitEntType CAltiumCircuitNote::GetUnitType() const
{
	return ALTIUM_CIRCUIT_NOTE;
}
